//
//  Foot.m
//  TapEnglish
//
//  Created by 이선동 on 11. 4. 13..
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Foot.h"


@implementation Foot

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [labelCaption release];
    [labelPinyin release];
    [labelEnglish release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [labelCaption release];
    labelCaption = nil;
    [labelPinyin release];
    labelPinyin = nil;
    [labelEnglish release];
    labelEnglish = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)viewWillAppear:(BOOL)animated {
    [self soundPlay:@"KOR_foot.aiff"];    
}

- (IBAction)goHome:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)speakerTapped:(id)sender {
    [self soundPlay:[NSString stringWithFormat:@"KOR_%@.aiff", labelEnglish.text]];
}

SystemSoundID soundID;

CFURLRef baseURL;

- (void) soundPlay:(NSString *)audioName{
	NSString *sndPath = [[NSBundle mainBundle] pathForResource:audioName ofType:nil];
	baseURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:sndPath];
	AudioServicesCreateSystemSoundID(baseURL, &soundID);
	AudioServicesPlaySystemSound(soundID);
}

- (IBAction)button_23_tapped_leg:(id)sender {
    [self soundPlay:@"KOR_calf.aiff"];
    labelCaption.text=@"종아리";
    //labelPinyin.text=@"あし";
    labelEnglish.text=@"calf";
}

- (IBAction)button_24_tapped_foot:(id)sender {
    [self soundPlay:@"KOR_foot.aiff"];
    labelCaption.text=@"발";
    //labelPinyin.text=@"あし";
    labelEnglish.text=@"foot";
}

- (IBAction)button_25_tapped_toe:(id)sender {
    [self soundPlay:@"KOR_toe.aiff"];
    labelCaption.text=@"발가락";
    //labelPinyin.text=@"あしのゆび";
    labelEnglish.text=@"toe";
}

@end
